<html>

<head>

  <title>TFontCache</title>

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="../../../../../Styles/Default.css" type="text/css">

  <meta name="Ancestor" content="">
<script type="text/javascript" src="../../../../../CodeScripts/SyntaxHighlighter/scripts/shCore.js"></script><script type="text/javascript" src="../../../../../CodeScripts/SyntaxHighlighter/scripts/shBrushDelphi.js"></script><script type="text/javascript" src="../../../../../CodeScripts/SyntaxHighlighter/scripts/shBrushCpp.js"></script><script type="text/javascript" src="../../../../../CodeScripts/SyntaxHighlighter/scripts/shBrushCSharp.js"></script><link rel="stylesheet" type="text/css" href="../../../../../Styles/default.css"/><link rel="stylesheet" type="text/css" href="../../../../../Menu/menu.css"/><link rel="stylesheet" type="text/css" href="../../../../../CodeScripts/SyntaxHighlighter/styles/shCoreDefault.css"/><link rel="stylesheet" type="text/css" href="../../../../../CodeScripts/SyntaxHighlighter/styles/shThemeDefault.css"/><meta name="viewport" content="width=device-width, initial-scale=1.0"><script type="text/javascript" src="../../../../../Menu/menu.js"></script><script type="text/javascript" src="../../../../../CodeScripts/bootstrap.js"></script>
</head>

<body bgcolor="#FFFFFF">
  <div class="menu" id="menu"><a class="ancestor" href="../../../../_Body.htm">Index</a><a class="ancestor" href="../../_Body.htm">Img32.Text</a><span class="active">TFontCache</span>
  </div><br><br>

  <h1>TFontCache</h1>

  <p><span class="monobold">TFontCache</span> dramatically improves text rendering performance over directly accessing <span class="monobold">TFontReader</span> objects. Font files only need to be parsed once for each character accessed, and the glyph data returned is cached for later reuse.<br><br> 
    <div class="code">
      <pre class="brush: delphi;">
const
  text = 'some text';
var
  image       : TImage32;
  rec         : TRect;
  arialReader  : TFontReader;
  arial14Cache: TFontCache;
begin
  ... 
  //The following line of code assumes compiling to the Windows platform.
  //For cross-platform applications, consider storing the font in the
  //application's resource section, and loading it from there.
  arialReader := TFontReader.Create('Arial'); 
  //create a font cache for arialReader (with font height 14)
  arial14Cache := TFontCache.Create(arialReader, DpiAware(14));
  try
    //now do something with arial14Cache
    DrawText(image, rec, text, taCenter, tvaMiddle, arial14Cache);
  finally
    //clean up
    arialReader.Free;
    arial14Cache.Free;
  end;
      </pre>
    </div> </p>

  <h2 id="Auto-Reference">Reference</h2>
  <p>
    <table class="autoTbl">
      <tr>
        <th>Methods</th>
        <th style="width: 100%;">Properties</th>
      </tr>
      <tr>
        <td><a href="Methods/Clear.htm">Clear</a>
        </td>
        <td><a href="Properties/Ascent.htm">Ascent</a>
        </td>
      </tr>
      <tr>
        <td><a href="Methods/Create.htm">Create</a>
        </td>
        <td><a href="Properties/Descent.htm">Descent</a>
        </td>
      </tr>
      <tr>
        <td><a href="Methods/Destroy.htm">Destroy</a>
        </td>
        <td><a href="Properties/FontHeight.htm">FontHeight</a>
        </td>
      </tr>
      <tr>
        <td><a href="Methods/GetAngledTextGlyphs.htm">GetAngledTextGlyphs</a>
        </td>
        <td><a href="Properties/FontReader.htm">FontReader</a>
        </td>
      </tr>
      <tr>
        <td><a href="Methods/GetCharInfo.htm">GetCharInfo</a>
        </td>
        <td><a href="Properties/InvertY.htm">InvertY</a>
        </td>
      </tr>
      <tr>
        <td><a href="Methods/GetCharOffsets.htm">GetCharOffsets</a>
        </td>
        <td><a href="Properties/Kerning.htm">Kerning</a>
        </td>
      </tr>
      <tr>
        <td><a href="Methods/GetTextOutline.htm">GetTextOutline</a>
        </td>
        <td><a href="Properties/LineHeight.htm">LineHeight</a>
        </td>
      </tr>
      <tr>
        <td><a href="Methods/GetTextWidth.htm">GetTextWidth</a>
        </td>
        <td><a href="Properties/Scale.htm">Scale</a>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td><a href="Properties/StrikeOut.htm">StrikeOut</a>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td><a href="Properties/Underlined.htm">Underlined</a>
        </td>
      </tr>
    </table></p>
  <p class="Copyright" id="auto"> <br><br> Copyright &copy;2010-2023 Angus Johnson&nbsp; - &nbsp;Image32 4.2&nbsp; - &nbsp;Help file built on 26 Mar 2023 <br><br> </p>

</body>
</html>